function login(){
	var username 	= $("#username").val();
	var userpsw 	= $("#userpsw").val();
	var captcha 	= $("#captcha").val();
	
	$.ajax({
	   type: "POST",
	   url: "login",
	   data: "account=" + username + "&password=" + userpsw + "&captcha=" + captcha,
	   success: function(u){
	   	console.info(u);
	     if(u){
	     	console.log("登录成功！！！");
	     	window.location.href="page_index.html";
	     }
	   },
	   error:function(resp){
	   	console.error(resp);
	   	if(resp.status===401){
	   		refreshCaptcha();
	   		$(".errormsg").html("登录失败，请检查用户名或密码");
	   	}
	   }
	});
	//console.info(username,userpsw,captcha);
}

function refreshCaptcha(){
	var random = (new Date()).toString();
    var captchaUrl = "captcha/generate" + "?cb=" + random;
    $(".captcha_img").attr("src",captchaUrl);
}
